package com.buka.controller;

import com.buka.domain.ResponseResult;
import com.buka.pojo.Menu;
import com.buka.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class MenuController {

    @Autowired
    private MenuService menuService;

    @GetMapping("/system/menu/list")
    public ResponseResult list(@RequestParam(defaultValue = "-1") int status, String menuName) {
        return menuService.list(status, menuName);
    }

    @PostMapping("/system/menu")
    public ResponseResult add(@RequestBody Menu menu) {
        return menuService.add(menu);
    }

    @DeleteMapping("/system/menu/{id}")
    public ResponseResult deleteMenu(@PathVariable("id") int id) {
        return menuService.deleteMenu(id);
    }

    @GetMapping("/system/menu/{id}")
    public ResponseResult getMenuById(@PathVariable("id") int id) {
        return menuService.getMenuById(id);
    }

    @GetMapping("/system/menu/treeselect")
    public ResponseResult treeSelect() {
        return menuService.treeSelect();
    }

    @GetMapping("/system/menu/roleMenuTreeselect/{id}")
    public ResponseResult roleMenuTreeselect(@PathVariable("id") int id) {
        return menuService.roleMenuTreeselect(id);
    }
}
